//引入请求的方法
import {request} from '../../request/index.js';
//Page Object
Page({
  data: { 
    //轮播图数组
    swipwerList:[],
    //导航数组
    catesList:[],
    //楼层数据
    floorList:[]
  }, 
  //获取轮播图数据 
  getSwiperList(){
    request({url:'https://api-hmugo-web.itheima.net/api/public/v1/home/swiperdata'})
    .then(result=>{
     this.setData({
          swipwerList:result.data.message
        })
        //console.log(result);
    })
  },


  //获取分类导航数据
  getCatesList(){
    request({url:'https://api-hmugo-web.itheima.net/api/public/v1/home/catitems'})
    .then(result=>{
      this.setData({
        catesList:result.data.message
      })
      //console.log(result.data.message);
    })
  },


  //获取分类导航数据
  getFloorList(){
    request({url:'https://api-hmugo-web.itheima.net/api/public/v1/home/floordata'})
    .then(result=>{
      this.setData({
        floorList:result.data.message
      })
      //console.log(result);
    })
  },
  //options(Object)
  onLoad: function(options) {
    // //异步请求获取数据 通过promise解决
    // var reqTask = wx.request({
    //   url: 'http://api.hcoder.net/api/index.php?token=...&c=imgNews&m=imgnewsItems&imgnewsid=7',
    //   success: (result) => {
    //     console.log(result);
    //     this.setData({
    //       swipwerList:[{
    //         id:0,
    //         url:'../../swiperPicture/布达拉宫1.jpg'
    //       },{
    //         id:1,
    //         url:'../../swiperPicture/布达拉宫2.jpg'
    //       },{
    //         id:2,
    //         url:'../../swiperPicture/布达拉宫3.jpg'
    //       }]
    //     })
    //   }
    // });

    this.getSwiperList();  

    this.getCatesList();

    this.getFloorList();
      
  }



  
 
});
